package cn.gson.crm.controller.job;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.JobFollowDao;
import cn.gson.crm.model.dao.StudentDao;
import cn.gson.crm.model.po.JobFollowPo;

@WebServlet("/job/file")
public class FileStudentServlet extends BaseServlet{

	/**
	 * 学生归档
	 */
	private static final long serialVersionUID = 1L;
	JobFollowDao jobDao = new JobFollowDao();
	StudentDao stuDao = new StudentDao();
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String p = request.getParameter("page");
		String name = request.getParameter("name");
		String phone = request.getParameter("phone");
		String[] ids = request.getParameterValues("id"); 
		if(p==null||p.isEmpty()){
			p="1";
		}
		Integer page = Integer.parseInt(p);
		//学员归档
		if(ids!=null){
			for (String id : ids) {
				stuDao.changeStuGrade("11", id);
			}
		}
		//获取已归档的学员
		List<JobFollowPo>studentList = jobDao.getJobFollowList(page, "11", "正常", name, phone);
		Integer totalPage = jobDao.getJobFollowListTotalPage("11", "正常", name, phone);
		request.setAttribute("studentList", studentList);
		request.setAttribute("totalPage", totalPage);
		request.setAttribute("page", page);
		request.setAttribute("queryString", noPageQueryString(request));
		getServletPathAndForward(request, "job/stu_worked.jsp");
	}
}
